const pageConfig = {
    data() {
        return {
            zzlyfbData: {},
            showChinaMap: false,
            // 获取地图来源类型  1 国内 2 国外
            mapType: 1,
            mapTypeList: [
                { name: "全球分布", value: 1 },
                { name: "中国分布", value: 2 },
            ],
            // 中国地图图例 1 品种来源 2 品种共享
            chinaLegendActive: [1, 2],
            chinaLegendList: [
                { name: "品种来源", value: 1, icon: "./img/left-line.png" },
                { name: "品种共享", value: 2, icon: "./img/right-line.png" },
            ],
        }
    },
    methods: {
        /**
         * 地图类型点击
         */
        mapTypeClick(item) {
            if ( this.mapType == item.value ) {
                return;
            }
            this.mapType = item.value;
            if (item.value == 1) {
                this.showChinaMap = false;
                this.$nextTick(() => {
                    worldMapCharts(this.zzlyfbData && this.zzlyfbData.foreignList || []);
                })
            } else {
                this.showChinaMap = true;
            }
        },
        /**
         * 中国地图图例点击 
         * */
        chinaLegendChange(val) {
            if (this.chinaLegendActive.includes(val)) {
                this.chinaLegendActive = this.chinaLegendActive.filter(item => item != val);
            } else {
                this.chinaLegendActive.push(val);
            }
        },
        /**
         * 获取种质来源分布数据
         */
        getZzlyfbData() {
            let params = {};
            tpHttp.post(this, "action=com.top.xjzykt.germplasm.dp.statCropByArea", { param: JSON.stringify(params) }, (data, code, message) => {
                if (code == 0 && data) {
                    data.foreignList = data.foreign_list;
                    data.domesticList = data.domestic_list;
                    this.zzlyfbData = data;
                } else {
                    this.zzlyfbData = {};
                }
                this.getZzlyfbSlData();
            })
        },
        /**
         * 获取申领区域列表
         */
        getZzlyfbSlData() {
            let params = {};
            tpHttp.post(this, "action=com.top.xjzykt.apply.getApplyAreaList", { param: JSON.stringify(params) }, (data, code, message) => {
                if (code == 0 && data && data.length > 0) {
                    this.zzlyfbData.slList = data;
                }
                
                this.$nextTick(() => {
                    worldMapCharts(this.zzlyfbData && this.zzlyfbData.foreignList || []);
                })
            })
        }
    },
    mounted() {
        this.getZzlyfbData();
    },
}